/*************************************************************************
	> File Name: P1036.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2024-12-03 14:12:11
 ************************************************************************/
#include <iostream>
#include <cmath>
using namespace std;

#define MAX_N 20
int arr[MAX_N + 5];
int n, k, ans = 0;

int is_prime(int n) {
    for (int i = 2, I = sqrt(n); i <= I; i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}

void dfs(int m, int sum, int start_x) {
    if (m == k) {
        ans += is_prime(sum);
        return ;
    }
    for (int i = start_x; i < n; i++) {
        dfs(m + 1, sum + arr[i], i + 1);
    }
    return ;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    dfs(0, 0, 0);
    cout << ans << endl;
    return 0;
}
